<?php
//	$subject = new Subject();
	$school = $_SESSION['school'];
//	$subject = $_REQUEST['subject'];
//	$subjects = $_REQUEST['subjects'];
?>
<script type="text/javascript" src="js/subject.js"></script>
<input type="hidden" id="schoolid" value="<?php echo $school->getId(); ?>" />
<input type="hidden" id="facultyid" value="<?php echo $_SESSION['facultyid']; ?>" />
<input type="hidden" id="departmentid" value="<?php echo $subject->getDepartmentid(); ?>" />
<input type="hidden" id="subjectid" value="<?php echo $subject->getId(); ?>" />
<input type="hidden" id="semesterid" value="<?php echo $_SESSION['currsemester']->getId(); ?>" />
<!-- Must have page id (for notice use) -->
<input type="hidden" id="pageid" value="4" />
<!-- Must have reference id (for notice use) -->
<input type="hidden" id="referenceid" value="<?php echo $subject->getId(); ?>" />
<div class="ui-corner-all"><?php include "view/topmenu.php"; ?></div>
<div class="block">
	Welcome <?php 
		if(!empty($_SESSION['user'])){
			$user = $_SESSION['user'];
			echo $user->getName();
		}
	?> :
	<a href="javascript:void(0)" id="linkHome">Home</a> &gt;
	<a href="javascript:void(0)" id="linkFaculty">Faculty</a> &gt;
	<a href="javascript:void(0)" id="linkDepartment">Department</a> &gt;
	<b>Subject</b>
</div>
<div class="block">
	<!-- Subject -->
	<fieldset>
		<legend id="subjectname"><?php echo $subject->getName(); ?></legend>
		<span id="spnSubjectDesc" name="spnSubjectDesc"><?php echo $subject->getDescription(); ?></span>
		<?php HTMLUtil::EditButton("editSubjectDesc");  ?>
		<br/>
	</fieldset>
	<!-- Notice -->
	<?php include_once "view/view_ext_notice.php";	?>
	<!-- Subjects !!! NEED REQRITE, USE <TABLE> !!! -->
	<fieldset>
		<legend>Class</legend>
		<table id="classlist" width="100%">
			<tr>
				<th class="ui-widget-content ui-corner-all">Lecturer</th>
				<th class="ui-widget-content ui-corner-all">Description</th>
				<th class="ui-widget-content ui-corner-all">Time</th>
				<th class="ui-widget-content ui-corner-all">Location</th>
				<th class="ui-widget-content ui-corner-all">&nbsp;</th>
			</tr>
			<?php
				foreach($clazzes as $clazz){
					echo "<tr id=\"trclass" . $clazz->getId() . "\" class=\"ui-widget-content ui-corner-all\">";
					echo "<td class='aligntop ui-widget-content ui-corner-all'>" . $clazz->getPicname() . "</td>";
					echo "<td class='aligntop ui-widget-content ui-corner-all'>" . $clazz->getDescription() . "</td>";
					echo "<td class='aligntop ui-widget-content ui-corner-all' style='text-align: right' width='200'>" . 
						$clazz->getTimetable()->getDay() . ', ' . 
						$clazz->getTimetable()->getStarttime() . ' to ' .
						$clazz->getTimetable()->getEndtime() .
						"</td>";
					echo "<td class='aligntop ui-widget-content ui-corner-all'>" . $clazz->getTimetable()->getLocation() . "</td>";
					echo "<td class='aligntop ui-widget-content ui-corner-all' width='80'>";
					HTMLUtil::WriteActionButton("View", "viewClass('" . $clazz->getId() . "')");
					echo " ";
					HTMLUtil::WriteActionButton("Delete", "deleteClass('" . $clazz->getId() . "')");
					echo "</td>";
					echo "</tr>\n";
				}
			?>
		</table>	
		<div class="block">
			<?php HTMLUtil::AddButton("addClass"); ?>
		</div>
	</fieldset>
	
	<!-------------------------------------- Diaologs ---------------------------------->
	<div id="dialog_subject_desc" title="Subject Description">
		<label for="newsubjectname">Name</label>
		<input type="text" id="newsubjectname" class="text ui-widget-content ui-corner-all"/>
		<textarea id="subjectdesc" name="subjectdesc" cols="50" rows="8" class="text ui-widget ui-corner-all"></textarea>
	</div>
	
	<div id="dialog_new_class" title="New Class">
		<fieldset>
			Lecturer: <select id="lecturer"></select><br>
			Description: <br>
			<textarea id="class_description" name="class_description" cols="50" rows="4" class="text ui-widget ui-corner-all"></textarea>
			Timetable: <br><select id="weekday"></select><br>
			<select id="fromhour"></select>:<select id="fromminutes"></select><select id="fromampm"></select> to
			<select id="tohour"></select>:<select id="tominutes"></select><select id="toampm"></select><br>
			Vanue: <input type="text" id="location" class="text ui-widget-content ui-corner-all"/>
		</fieldset>
	</div>
	
</div>